package com.os.osframe.scaffold.velocity;

import com.os.osframe.scaffold.domain.ScaffoldXmlTable;
import com.os.osframe.scaffold.xml.ReadXmlObj;

import java.util.List;

/**
 * 自动生成代码工厂
 * Created by wangdc on 2018-4-27.
 */
public class AutoCreateFactory {
    /**
     * 创建所有代码
     * @param packages
     * @throws Exception
     */
    public static void createCode(String packages) throws Exception{
        List list= ReadXmlObj.getXmlObjList(packages);//读取配置的xml信息
        if(list==null || list.isEmpty()){
            System.out.println("未读取到任何表信息或读取xml信息异常");
            return;
        }
        for(int i=0;i<list.size();i++){//循环创建每个表的jsp和类文件
            CreateCode baseCreate=new CreateCode((ScaffoldXmlTable)list.get(i));
            baseCreate.getParams(packages);
            baseCreate.create(packages);
        }

    }

}
